from django.http import HttpResponse
from django.shortcuts import render

# Create your views here.
from django.utils.decorators import method_decorator
from django.views import View

def my_decorator(func):
    def wrapper(request,*args,**kwargs):
        print("这是一个装饰器")
        print("被装饰的path%s"%request.path)
        return func(request,*args,**kwargs)
    return wrapper

# @method_decorator(my_decorator,name="dispatch")   #这个是装饰本类的所有的方法
# @method_decorator(my_decorator,name="get")   #这个是装饰本类的get的方法
class IndexView(View):
    # @method_decorator(my_decorator)  #这个是装饰自己确定的函数方法
    def get(self,request):
        print("get方法")
        return HttpResponse("这个是get方法")

    # @method_decorator(my_decorator)
    def post(self,request):
        print("post方法")
        return HttpResponse("这个是post方法")



